<!DOCTYPE html>
<html>
<head>
    @include("/template/inc/inc.html"){}
    <title>文件上传示例</title>
    <script>
        function submitF1() {
            $.messager.progress();
            $('#f1').form('submit', {
                url: '${ctxPath}/upload',
                onSubmit: function () {
                    var isValid = $(this).form('validate');
                    if (!isValid) {
                        $.messager.progress('close');
                    }
                    return isValid;
                },
                success: function (data) {
                    $.messager.progress('close');
                    var data = eval('(' + data + ')');
                    alert(data.msg);
                    if (data.success) {
                        var html = [];
                        for (var i = 0; i < data.obj.length; i++) {
                            var a = '<a href="${ctxPath}/download?url={0}">下载：{1}</a><br/>'.replace('{0}', data.obj[i]).replace('{1}', data.obj[i]);
                            html.push(a);
                        }
                        $('#d').html(html.join(''));
                    }
                }
            });
        }
    </script>
</head>
<body>
<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'center',title:''">
        <form id="f1" method="post" enctype="multipart/form-data">
            <input name="url" class="easyui-textbox" data-options="prompt:'上传路径',required:true
                                                ,width:'49%',value:'upload'">
            <input name="file" class="easyui-filebox" data-options="prompt:'请选择要上传的文件'
                                                ,width:'24%'
                                                ,buttonText:'选择文件'">
            <input name="file" class="easyui-filebox" data-options="prompt:'请选择要上传的文件'
                                                ,width:'24%'
                                                ,buttonText:'选择文件'">
            <br/>
            <a class="easyui-linkbutton" data-options="size:'large',width:'98.9%'" href="javascript:void(0);" onclick="submitF1();">上传</a>
        </form>
        <div id="d"></div>
    </div>
</div>
</body>
</html>